'use strict';
import * as Koa from 'koa';
import { router, prefix } from '../middleware/router';
import { response } from '../middleware/result';
import { winelistService } from '../service/winelist';

/** 酒水对象 */
@prefix('winelist')
class WineListController {
    @router('/query', { method: 'post' })
    async query(ctx: Koa.Context) {
        let result = await winelistService.query(ctx.request.body);
        response(ctx, result);
    }
    @router('/save', { method: 'post' })
    async save(ctx: Koa.Context) {
        let result = await winelistService.save(ctx.request.body);
        response(ctx, result);
    }
    @router('/delete/:id')
    async delete(ctx: Koa.Context) {
        let result = await winelistService.delete(ctx.params.id);
        response(ctx, result);
    }
    @router('/queryById/:id')
    async queryById(ctx: Koa.Context) {
        let result = await winelistService.queryById(ctx.params.id);
        response(ctx, result);
    }
    @router('/open/:id')
    async open(ctx: Koa.Context) {
        let result = await winelistService.open(ctx.params.id);
        response(ctx, result);
    }
    @router('/lock/:id')
    async lock(ctx: Koa.Context) {
        let result = await winelistService.lock(ctx.params.id);
        response(ctx, result);
    }
}